<template>
  <div>
    <el-menu
      :default-active="activeDefault"
      class="el-menu-vertical-demo"
      v-if="store.state.userData.type == 1"
    >
      <el-menu-item
        @click="hanleGourl(item)"
        v-for="(item, index) in tealist"
        :key="item.path"
        :index="`${index + 1}`"
      >
        <i :class="item.icon" style="font-size: 20px"></i>
        <span slot="title" v-text="item.title" style="font-size: 16px"></span>
      </el-menu-item>
    </el-menu>
    <el-menu
      :default-active="activeDefault"
      class="el-menu-vertical-demo"
      v-else
    >
      <el-menu-item
        @click="hanleGourl(item)"
        v-for="(item, index) in stulist"
        :key="item.path"
        :index="`${index + 1}`"
      >
        <i :class="item.icon" style="font-size: 20px"></i>
        <span slot="title" v-text="item.title" style="font-size: 16px"></span>
      </el-menu-item>
    </el-menu>
  </div>
</template>
<script>
import store from "@/store";
export default {
  name: "MMenu",
  props: {
    persontype: {
      type: String,
      default: "all",
    },
    activeDefault: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      store,
      stulist: [
         {
          title: "个人信息",
          path: "/information",
          type: "all",
          icon: "el-icon-user-solid",
        },
        {
          title: "练习记录",
          path: "/studentrecord",
          type: "student",
          icon: "el-icon-s-order",
        },
       {
          title: "错题记录",
          path: "/wrongquestionrecord",
          type: "student",
          icon: "el-icon-s-release",
        },
      ],
      tealist: [
        {
          title: "个人信息",
          path: "/information",
          type: "all",
          icon: "el-icon-user-solid",
        },
        {
          title: "班级管理",
          path: "/personalcenter",
          type: "all",
          icon: "el-icon-s-tools",
        },
        {
          title: "练习记录",
          path: "/teacherrecord",
          type: "teacher",
          icon: "el-icon-s-order",
        },
        {
          title: "学习时长统计",
          path: "/timecount",
          type: "teacher",
          icon: "el-icon-s-marketing",
        },
        {
          title: "错题集",
          path: "/wrongquestion",
          type: "teacher",
          icon: "el-icon-s-management",
        },
      ],
    };
  },
  methods: {
    // 导航栏切换
    hanleGourl(item) {
      if (item.path === this.$router.currentRoute.fullPath) {
        return;
      }
      this.$router.push(item.path);
    },
  },
};
</script>

<style scoped lang="scss">
$green: #000;
::v-deep .el-menu-item.is-active {
  border-left: 5px solid;
}
.el-menu {
  border-right: none;
}
.el-menu-vertical-demo {
  padding: 20px 0px;
}
</style>
